#include <iostream>
#include <cstring>
#include "comm.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cerrno>
using namespace std;

int main()
{
    int wfd = open(FILENAME, O_WRONLY);
    if(wfd < 0)
    {
        cerr << "errno: " << errno << ", errstring: " << strerror(errno) << endl;
        return 1;
    }
    cout << "open fifo success...write" << endl;

    string message;

    while(true)
    {
        cout << "Please Enter# ";
        getline(cin, message);

        ssize_t s = write(wfd, message.c_str(), message.size());
        if(s < 0)
        {
            cerr <<"errno: " << errno << ", errstring: " << strerror(errno) << endl;
            break;
        }


    }

    close(wfd);
    cout << "close fifo success...." << endl;


    return 0;
}